package com.mate.cloud.chain.handler;

import com.mate.cloud.chain.constant.MembershipLevel;
import com.mate.cloud.chain.domain.User;

public class PremiumMemberDiscountHandler extends DiscountHandler {

    @Override
    public double applyDiscount(double amount, User user) {
        if (user.getMembershipLevel() == MembershipLevel.BASIC) {
            // Premium会员享受10%折扣
            return amount * 0.9;
        }else if(nextHandler!=null){
            return nextHandler.applyDiscount(amount, user);
        }else {
            return amount;
        }

    }
}
